package com.example.composableexample

import android.os.Build.VERSION.SDK_INT
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.tooling.preview.Preview
import coil.ImageLoader
import coil.compose.AsyncImage
import coil.decode.GifDecoder
import coil.decode.ImageDecoderDecoder

/**
 * author: LiLiang
 * createTime: 2022/9/21-14:39
 * remark:
 **/
@Preview
@Composable
fun CoilSimple() {

    val imageUrl = "https://img-blog.csdnimg.cn/6c05e53ae2994b6ab931daa94941a86a.gif"
    val imageLoader = ImageLoader.Builder(LocalContext.current)
        .components {
            if (SDK_INT >= 28) {
                add(ImageDecoderDecoder.Factory())
            } else {
                add(GifDecoder.Factory())
            }
        }
        .build()
    AsyncImage(model = imageUrl, contentDescription = "", imageLoader = imageLoader)


}